<!--
  // Creation History
  // --------------------------------------------------------------
  //	Company:			HTHK
  //	NAME:				StaffProject.jsp
  //	TITLE:				Local Cost
  //	FUNCTION:			Add or Update Staff Project.
  //	BY:				Poly Li
  //	DATE:				12/01/2004
  // --------------------------------------------------------------
-->

<%@ include file="../tssheader.jsp"   %>
<%@ page import="tss.multiproject.*" %>
<%@ page import="tss.options.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>

<script language="JavaScript" >

function formValidation()
{
        var d1=fm.project_name;
        var d2=fm.staff_name;
	if(isNull(d1,"Project Name ")||isNull(d2,"Staff Name"))
		return false;
    
	return true;
}

</script>

<%
	//Get A Staff Project Code list
	MultiStaffOptions staffProjectOptions = new MultiStaffOptions();
	ProjectOptions projectOptions = new ProjectOptions();

    //Get A Staff Project
	StaffProjectBean staffProject = (StaffProjectBean)request.getAttribute("staffProject");
	if (staffProject == null)
	{   staffProject = new StaffProject();}
	String staff_name[] = null;
	if(request.getAttribute("staff_name") != null)
		staff_name = (String[])request.getAttribute("staff_name");
	String projectName = null;
	if(request.getParameter("project_name") != null)
		projectName = request.getParameter("project_name");
	
	StaffProjectBean[] staffProjects = (StaffProjectBean[])request.getAttribute("staffProjects");
	if (staffProjects == null)
	{   staffProjects = new StaffProject[0];}
	String customOptions = null;
	if(request.getAttribute("customOptins") != null)
		customOptions = (String)request.getAttribute("customOptins");
    boolean readonlyFlag = true;
    formAction = request.getParameter("formAction");
    if (formAction.equals("Create"))
	{
		readonlyFlag = false;
        }
%>
<body>

<h2>Staff Multi Project Maintenance</h2>

<form id=fm method=post action=<%=contextPath%>/servlet/tss.multiproject.StaffProjectServlet>
<input type=hidden name=formAction value=<%=formAction%> >
<table cols=10 border=0 >
<tr>
  <td>Project Name:</td>
  <td>&nbsp;</td>
  <td>
<%	if(projectName == null){	%>
	<select name=project_name>
		<%=projectOptions.getOptions(staffProject.getProject_name(),readonlyFlag)%>
	</select>
<%	}else{	%>
	<input type=hidden name="project_name" value="<%= projectName %>">
		<%= projectName %>
<%	}	%>
  </td>
</tr>

<tr>
  <td valign=top>Staff Name:</td>
  <td>&nbsp;</td>
  <td>
<%
	if (!readonlyFlag)
	{
%>
  <select name=staff_name size=10 multiple>
  <!--<%= staffProjectOptions.getOptions(staffProject.getStaff_no(),readonlyFlag) %>-->
  <%= staffProjectOptions.orderOptions() %>
  </select>
<%	}else{	%>
	<select name=staff_name size=10 multiple>
	<%= customOptions %>
	</select>
<%	}	%>
  </td>
</tr>

</table>
<br>
<hr>

<p>
	<INPUT type=button value=Save onclick="save()">
	<INPUT type=reset  value=Cancel >
<%	if (!formAction.equals("Create")){	%>
	<INPUT type=button value=Delete  onclick="deleteRecord()"  >
<%	}	%>
	<INPUT type=button value=Back onclick=history.back() >
</p>
</form>
<%@ include file="../tssfooter.jsp" %>
</body>
</body>
</html>

